import {food_type_detail} from '../../network/interface'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    Id:0,
    zan1:20,
    zan2:34,
    zan3:56,
    value1: 3,
    value2: 4,
    isCollect1:true,
    isCollect2:true,
    isCollect3:true,

    foodTypeDescription:"",
    foodList:[],
    foodTypeName:""
  },
  onChange(event) {
    this.setData({
      value1: event.detail,
      value2: event.detail,
    });
  },
  selectType: function(e){
    var index = e.currentTarget.dataset.index
    this.setData({
      Id:index,
    });
  },
  tointroduce:function(e){
    var Sid = e.currentTarget.dataset.sid
    wx.setStorage({
      key:"Sid",
      data:Sid
    })
    wx.navigateTo({
      url: '/pages/foodIntroduce/foodIntroduce'
    })
  },

  toZan1(){
    var bol1 =this.data.isCollect1;   //获得状态
    this.setData({
      isCollect1:!bol1  //改变状态
    })
  },
  toZan2(){
    var bol2 =this.data.isCollect2;   //获得状态
    this.setData({
      isCollect2:!bol2  //改变状态
    })
  },
  toZan3(){
    var bol3 =this.data.isCollect3;   //获得状态
    this.setData({
      isCollect3:!bol3  //改变状态
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that =this;
    let param={}
    param.id=options.id;
    wx.showLoading({
      title: '加载中',
    })
    food_type_detail(param,res=>{
      console.log(res)
      that.setData({
        foodTypeDescription:res.data.foodTypeDescription,
        foodList:res.data.foodList,
        foodTypeName:options.name
      })
      wx.hideLoading({
        success: (res) => {},
      })
    })
  },

  toDetail(e){
    var foodId = e.currentTarget.dataset.id

    wx.navigateTo({
      url: '/pages/foodIntroduce/foodIntroduce?id='+foodId
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var index = 0
    index = wx.getStorageSync('Id')
    this.setData({
      Id:index,
    });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {


  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})